package com.demo.security.access.audit.prepost;

import com.demo.security.access.LogicAttribute;
import com.demo.security.access.audit.AuditModel;

public class PostInvocationAuditAttribute implements PostAuditAttribute {

	/**
	 * 版本序列化ID
	 */
	private static final long serialVersionUID = 8493335456686156218L;
	private final AuditModel auditModel;
	/**
	 * 构造函数
	 * @param level 级别
	 * @param code 编码
	 * @param info 信息
	 * @param targetClass 目标类
	 */
	public PostInvocationAuditAttribute(int level, String code, String info, String targetClass) {
		auditModel = new AuditModel(level, code, info, targetClass);
	}

	public AuditModel getAuditModel() {
		return auditModel;
	}

	@Override
	public String getAttribute() {
		return auditModel.toString();
	}
	
    public int hashCode() {
        return super.hashCode();
    }
    
    public String toString() {
        return "PostInvocationAuditAttribute["
				+ (auditModel == null ? "-" : "Levle:" + auditModel.getLevel() 
				+ " Code:" + auditModel.getCode() 
				+ " Info:" + auditModel.getInfo())
				+ "];";
    }
    
	public boolean equals(Object obj) {
		if (obj instanceof LogicAttribute) {
			LogicAttribute attr = (LogicAttribute) obj;
			return this.auditModel.equals(attr.getAttribute());
		}
		return false;
	}
}
